﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Projekt.Models;

namespace Projekt.Cameras
{
    public class TargetCamera : BaseCamera
    {
        public CustomModel Target { get; set; }

        public TargetCamera(Vector3 Position, CustomModel Target, GraphicsDevice graphicsDevice)
            : base(graphicsDevice)
        {
            this.Position = Position;
            this.Target = Target;
        }

        public override void Update()
        {
            Vector3 forward = Target.Position - Position;
            Vector3 side = Vector3.Cross(forward, Vector3.Up);
            Vector3 up = Vector3.Cross(forward, side);
            this.View = Matrix.CreateLookAt(Position, Target.Position, -up);
        }
    }
}
